package org.apache.rocketmq.console.shiro.sevice.impl;

import javax.annotation.Resource;

import org.apache.rocketmq.console.shiro.dao.UserInfoDao;
import org.apache.rocketmq.console.shiro.dao.UserPermissionDao;
import org.apache.rocketmq.console.shiro.entity.UserInfo;
import org.apache.rocketmq.console.shiro.entity.UserPermission;
import org.apache.rocketmq.console.shiro.sevice.UserInfoService;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {
	@Resource
	private UserInfoDao userInfoDao;

	@Resource
	private UserPermissionDao userPermissionDao;

	@Override
	public UserInfo findByUsername(String username) {
		return userInfoDao.findByName(username);
	}

	@Override
	public UserPermission findUserPermissionById(int id) {
		// TODO Auto-generated method stub
		return userPermissionDao.findOneById(id);
	}

	@Override
	public boolean save(UserInfo userInfo) {
		try {
			userInfoDao.save(userInfo);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}

	}

}